﻿using MediatR;
using RBAC.LuFang.API.Application.Command.UserCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domin.Services;
using static System.Collections.Specialized.BitVector32;

namespace RBAC.LuFang.API.Application.CommandHandlers.UserHandler
{
    //用户添加
    public class UserCreateCommandHandler:IRequestHandler<UserCreateCommand,int>
    {
        private readonly IUserService _userService;

        public UserCreateCommandHandler(IUserService userService)
        {
            _userService = userService;
        }

        public async Task<int> Handle(UserCreateCommand request, CancellationToken cancellationToken)
        {
            var userModle = new UserInfo() { userName=request.userName, userSex=request.userSex, provinceID =request.provinceID , theCityID =request.theCityID , countyID =request.countyID , userAddress =request.userAddress , sectionId =request.sectionId };
            return await _userService.AddUser(userModle);
        }
    }
}
